#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    long long n,r[100007];
    bool checkr[100007],attack[100007];
    cin>>n;
    long long m=n;
    bool flag=true;
    for(long long i=0;i<n;i++)
    {
        cin>>r[i];
        if(r[i]!=1&&r[i]!=2) flag=false;
        checkr[i]=true;
        attack[i]=false;
    }
    if(flag==true)
    {
        for(long long i=0;i<n;i++)
        {
            if(r[i]==1) m-=1;
        }
        cout<<m<<endl;
        return 0;
    }
    sort(r,r+n);
    for(long long i=n-2;i>=0;i--)
    {
        if(checkr[i]==true)
        {
            if(r[i]>r[n-2-i]&&checkr[n-2-i]==true&&attack[i]==false)
            {
                checkr[n-2-i]=false;
                m-=1;
                attack[i]=true;
            }
        }
    }
    for(long long i=0;i<n-1;i++)
    {
        if(r[n-1]<r[i]&&checkr[i]==true)
        {
            cout<<m<<endl;
            return 0;
        }
    }
    cout<<m-1<<endl;
    return 0;
}
